<#include "/include/macros.ftl">
<@header></@header>
<div class="clearfix"></div>
<div class="row">
    <div class="col-md-12 col-sm-12 col-xs-12">
        <@breadcrumb>
            <ol class="breadcrumb">
                <li><a href="/">首页</a></li>
                <li class="active">友情链接管理</li>
            </ol>
        </@breadcrumb>
        <div class="x_panel">
            <div class="x_content">
                <div class="<#--table-responsive-->">
                    <div class="btn-group hidden-xs" id="toolbar">
                        <@shiro.hasPermission name="link:batchDelete">
                            <button id="btn_delete_ids" type="button" class="btn btn-danger" title="批量删除">
                                <i class="fa fa-trash-o fa-fw"></i>
                            </button>
                        </@shiro.hasPermission>
                    </div>
                    <table id="tablelist">
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<@addOrUpdateMOdal defaultTitle="添加内容">
    <input type="hidden" name="designId">
    <div class="item form-group">
        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="username">是否启用 <span class="required">*</span></label>

        <div class="col-md-6 col-sm-6 col-xs-12 fixed-radio-checkbox">
            <ul class="list-unstyled list-inline">
                <li><label for="anonymous" class="pointer"> <input type="radio" class="square" checked name="useState" value="0"> 开启 </label></li>
                <li><label for="anonymous" class="pointer"> <input type="radio" class="square" name="useState" value="1"> 禁用 </label></li>
            </ul>
        </div>

    </div>
</@addOrUpdateMOdal>
<@footer>
    <script>
        /**
         * 操作按钮
         * @param code
         * @param row
         * @param index
         * @returns {string}
         */
        function operateFormatter(code, row, index) {
            var trId = row.designId;
            var userId = row.userId;
            var operateBtn = [
                '<@shiro.hasPermission name="link:edit"><a class="btn btn-sm btn-success btn-design"  data-id="' + trId + '" data-userId="' + userId + '"title="查看"><i class="fa fa-align-justify fa-fw"></i></a></@shiro.hasPermission>',
                '<@shiro.hasPermission name="user:edit"><a class="btn btn-sm btn-success btn-update" data-id="' + trId + '"title="是否启用"><i class="fa fa-edit fa-fw"></i></a></@shiro.hasPermission>',
                '<@shiro.hasPermission name="link:delete"><a class="btn btn-sm btn-danger btn-pass" data-id="' + trId + '"title="审核"><i class="fa fa-circle-o-notch fa-spin"></i></a></@shiro.hasPermission>',
                '<@shiro.hasPermission name="link:delete"><a class="btn btn-sm btn-danger btn-remove" data-id="' + trId + '"title="删除"><i class="fa fa-trash-o fa-fw"></i></a></@shiro.hasPermission>'
            ];
            return operateBtn.join('');
        }

        $(function () {
            var options = {
                modalName: "友情链接",
                url: "/backstageRotationChart/softAll?page=1&count=1000",
                getInfoUrl: "/backstageRotationChart/getInfo?id={id}",
                updateUrl: "/backstageRotationChart/updateIn",
                removeUrl: "/backstageRotationChart/deleteSoft",
                createUrl: "/link/add",
                getJump :"/backstageRotationChart/get?id={id}",
                addSoft :"/backstageRotationChart/addSoft",
                pass: "/backstageRotationChart/pass?id={id}",
                columns: [
                    {
                        checkbox: true
                    }, {
                        field: 'designId',
                        title: 'id',
                        visible:false,
                        width: '120px',
                        formatter: function (code) {
                            return code;
                        }
                    },{
                        field: 'userId',
                        title: 'userId',
                        visible:false,
                        width: '120px',
                        formatter: function (code) {
                            return code;
                        }
                    },{
                        field: 'designTitle',
                        title: '标题',
                        width: '120px',
                        formatter: function (code) {
                            return code ? code : '-';
                        }
                    }, {
                        field: 'designStyle',
                        title: '风格',
                        width: '60px',
                        align: 'center',
                        formatter: function (code) {
                            if (code==="1"){
                                return "日式";
                            }else if (code==="2"){
                                return "中式";
                            }else if (code==="3"){
                                return "美式";
                            }else if (code==="4"){
                                return "欧式";
                            }else {
                                return code;
                            }
                        }
                    }, {
                        field: 'designApartment',
                        title: '户型',
                        width: '60px',
                        align: 'center',
                        formatter: function (code) {
                            if (code==="5"){
                                return "一室一厅一卫";
                            }else if (code==="6"){
                                return "两室一厅一卫";
                            }else if (code==="7"){
                                return "三室一厅一卫";
                            }else if (code==="8"){
                                return "四室一厅一卫";
                            }else {
                                return code;
                            }
                        }
                    }, {
                        field: 'designPlace',
                        title: '场所',
                        align: "center",
                        width: '80px',
                        formatter: function (code) {
                            if (code==="9"){
                                return "公寓";
                            }else if (code==="10"){
                                return "平房";
                            }else if (code==="11"){
                                return "KTV";
                            }else {
                                return code;
                            }
                        }
                    }, {
                        field: 'province',
                        title: '省',
                        width: '40px',
                        formatter: function (code, row, index) {
                            return code ? code : '-';
                        }
                    }, {
                        field: 'city',
                        title: '市',
                        width: '40px',
                        align: 'center',
                        formatter: function (code) {
                            return code ? code : '-';
                        }
                    }, {
                        field: 'area',
                        title: '区',
                        width: '60px',
                        align: 'center',
                        formatter: function (code) {
                            return code ? code : '-';
                        }
                    },{
                        field: 'top',
                        title: '是否置顶',
                        width: '40px',
                        formatter: function (code) {
                            if (code==="0"){
                                return "是";
                            }else if(code==="1"){
                                return "否";
                            }
                        }
                    },{
                        field: 'examine',
                        title: '是否通过',
                        width: '40px',
                        formatter: function (code) {
                            if (code==="0"){
                                return "审核通过";
                            }else if(code==="1"){
                                return "审核失败";
                            }else if(code==="2"){
                                return "审核中";
                            }
                        }
                    }, {
                        field: 'zanNumber',
                        title: '赞的数量',
                        width: '40px',
                        formatter: function (code) {
                            return code;
                        }
                    }, {
                        field: 'discussNumber',
                        title: '评论数量',
                        width: '40px',
                        formatter: function (code) {
                            return code;
                        }
                    },
                    {
                        field: 'addTime',
                        title: '发表时间',
                        align: "center",
                        width: '80px',
                        formatter: function (code) {
                            return code ? code : '-';
                        }
                    },
                    {
                        field: ' useState',
                        title: '是否启用',
                        align: "center",
                        width: '80px',
                        formatter: function (code) {
                            if (code==="0"){
                                return "启用";
                            }else if(code==="1"){
                                return "禁用";
                            }
                        }
                    },{
                        field: 'operate',
                        title: '操作',
                        align: "center",
                        width: '150px',
                        formatter: operateFormatter //自定义方法，添加操作按钮
                    }
                ],
                rowStyle: function (row, index) {
                    //这里有5个取值代表5中颜色['active', 'success', 'info', 'warning', 'danger'];
                    var strclass = "";
                    if (row.status) {
                        // strclass = 'success';//还有一个active
                    } else {
                        strclass = 'danger';
                    }
                    return { 'classes': strclass }
                }
            };
            // 初始化table组件
            var table = new Table(options);
            table.init();
        });

    </script>
</@footer>